﻿using System;
using System.Collections.Generic;
using Remind.Model;

namespace Remind.BLL
{
    /// <summary>
    /// 分组信息的业务类
    /// </summary>
    public class GroupBLL
    {
        Remind.IDAL.IGroup dal=Remind.DALFactory.DataAccess.CreateGroup();

        /// <summary>
        /// 查询所有分组信息
        /// </summary>
        /// <returns>所有分组信息</returns>
        public IList<GroupInfo> GetGroup()
        {
            return dal.GetGroups();
        }
        /// <summary>
        /// 根据分组名查询分组信息
        /// </summary>
        /// <param name="gName">分组名称</param>
        /// <returns></returns>
        public GroupInfo GetGroupByGname(string gName)
        {
            return dal.GetGroupByGname(gName);
        }
        //添加分组表信息
        public int AddGroup(string gName)
        {
            GroupInfo groupInfo = new GroupInfo { Gname = gName };
            return dal.EditGroup(groupInfo, Idu.insert); 
        }
        //编辑分组
        public int EditGroup(string gName,int gid)
        {
            GroupInfo grouInfo = new GroupInfo { Gname = gName, Gid = gid };
            return dal.EditGroup(grouInfo, Idu.update);
        }
        //删除分组
        public int DelGroup(GroupInfo groupInfo)
        {
            return dal.EditGroup(groupInfo, Idu.delete);
        }
        //根据分组编码查询分组名称
        public GroupInfo GetGroupInfoById(int gid)
        {
            return dal.GetGroupInfoById(gid);
        }
    }
}
